# Contributor: Simon Frankenberger <simon-alpine@fraho.eu>
# Maintainer: Simon Frankenberger <simon-alpine@fraho.eu>
pkgname=java-jtharness
pkgver=6.0_p10
_pkgver=${pkgver/_p/-b}
pkgrel=0
pkgdesc="The JT harness is a general purpose, fully-featured, flexible, and configurable test harness"
url="https://hg.openjdk.java.net/code-tools/jtharness"
arch="noarch !mips !mips64" # java
license="GPL-2.0"
makedepends="openjdk8"
options="!check" # this package has no tests
subpackages="$pkgname-doc:_doc $pkgname-examples:_examples"
source="jtharness-$_pkgver.tar.bz2::https://hg.openjdk.java.net/code-tools/jtharness/archive/jt$_pkgver.tar.bz2
https://archive.apache.org/dist/ant/binaries/apache-ant-1.9.13-bin.tar.bz2
https://repo1.maven.org/maven2/asm/asm-all/3.1/asm-all-3.1.jar
https://repo1.maven.org/maven2/junit/junit/4.4/junit-4.4.jar
https://repo1.maven.org/maven2/javax/servlet/javax.servlet-api/3.0.1/javax.servlet-api-3.0.1.jar
"
builddir="$srcdir/jtharness-jt$_pkgver"

_ant_home="$srcdir"/apache-ant-1.9.13/
_servletjar="$srcdir"/javax.servlet-api-3.0.1.jar
_bytecodelib="$srcdir"/asm-all-3.1.jar
_junitlib="$srcdir"/junit-4.4.jar

prepare() {
	default_prepare

	cd "$builddir/build"
	# configure the libraries
	sed -i \
		-e "s@^servletjar.\+@servletjar = $_servletjar@" \
		-e "s@^bytecodelib.\+@bytecodelib = $_bytecodelib@" \
		-e "s@^junitlib.\+@junitlib = $_junitlib@" \
		-e "s@^BUILD_DIR.\+@BUILD_DIR = $builddir/target@" \
		local.properties
}

build() {
	cd "$builddir/build"
	JAVA_HOME=/usr/lib/jvm/default-jvm $_ant_home/bin/ant
}

package() {
	_destdir="$pkgdir/usr/share/java/jtharness"
	mkdir -p "$_destdir"
	cp -r \
		$builddir/legal \
		$builddir/target/binaries/lib \
		"$_destdir"
}

_examples() {
	_destdir="$subpkgdir/usr/share/java/jtharness"
	mkdir -p "$_destdir"
	cp -r $builddir/examples "$_destdir"
}

_doc() {
	_destdir="$subpkgdir/usr/share/java/jtharness"
	mkdir -p "$_destdir"
	cp -r \
		$builddir/doc \
		"$_destdir"
}

sha512sums="f910c608dbc7f89066f47b355c18f561cfef429298e2e740fe678cb741ca847de97a821f542d38c96c34ba9bcd30661d852a773b29b75dcdcc91e2e8f9082fe8  jtharness-6.0-b10.tar.bz2
e9b602aacbac7bf721a830f56ea06cde60a7a674a6d67f05ce82848ac01b2ee84f7003190286fea1030abb523398fa1a280d265377f41f57e7cf7e6d1fe37465  apache-ant-1.9.13-bin.tar.bz2
00990aa9d39fe874f6799dc8d9d1b208b61e6358a949df86014edeacbea63dcdc4ac7870948a54270e1db4b8ec134313b200fe7cdede7aa6746c812c36f0ac13  asm-all-3.1.jar
4ae9fb09ebd9800ba1c9f0bfc43f07f7bc499e41894dea74b50f01fd69690b5d4e8f7949e2afce10fa0da719e8a2df223430e3aef7e2529662c7b70a12c80ab9  junit-4.4.jar
1e087f1e4632048f1c6ea12e3820a30c7a6e66b13277ec8e784d8c5aba99335cd90cdb08e23756e815324cc9c8dc22d0937c7ccf4b89ee00222cd5e4a1d2a0de  javax.servlet-api-3.0.1.jar"
